﻿// Decompiled with JetBrains decompiler
// Type: 我的小工具.AppMng
// Assembly: 开发辅助工具, Version=1.0.0.1, Culture=neutral, PublicKeyToken=null
// MVID: F78E5980-5E94-4E46-ABDF-DC8C6CBF52AA
// Assembly location: K:\Tools\工具\开发辅助工具庆六一版\开发辅助工具2015-06-01\开发辅助工具.exe

using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;

namespace 我的小工具
{
  internal class AppMng
  {
    public static void LogWrite(string requestinfo, string actiontype, string usercode)
    {
      Dictionary<string, string> dictionary = new Dictionary<string, string>();
      dictionary.Add("appid", "09CDA54A-DBB4-424F-8521-F8BBDFBC0C78");
      dictionary.Add("requestinfo", requestinfo);
      dictionary.Add("actiontype", actiontype);
      dictionary.Add("usercode", usercode);
      dictionary.Add("message", "");
      dictionary.Add("message2", "");
      dictionary.Add("message3", "");
      dictionary.Add("message4", "");
      HttpWebRequest httpWebRequest = WebRequest.Create("http://myapp.mysoft.net.cn:10077/App/Services/Portal/WriteLog") as HttpWebRequest;
      httpWebRequest.Method = "POST";
      httpWebRequest.ContentType = "application/x-www-form-urlencoded";
      StringBuilder stringBuilder = new StringBuilder();
      int num = 0;
      foreach (string key in dictionary.Keys)
      {
        if (num > 0)
          stringBuilder.AppendFormat("&{0}={1}", (object) key, (object) dictionary[key]);
        else
          stringBuilder.AppendFormat("{0}={1}", (object) key, (object) dictionary[key]);
        ++num;
      }
      byte[] bytes = Encoding.UTF8.GetBytes(stringBuilder.ToString());
      using (Stream requestStream = httpWebRequest.GetRequestStream())
        requestStream.Write(bytes, 0, bytes.Length);
      try
      {
        httpWebRequest.BeginGetResponse((AsyncCallback) null, (object) httpWebRequest);
      }
      catch
      {
      }
    }

    private static void RequestCallBack(IAsyncResult asynchronousResult)
    {
    }

    public static bool Default_Login(string strSite)
    {
      Random random = new Random(DateTime.Now.Millisecond);
      string requestUriString = strSite + "/Default_Login.aspx?rdnum=" + (object) random.Next();
      Dictionary<string, string> dictionary = new Dictionary<string, string>();
      dictionary.Add("usercode", "admin");
      dictionary.Add("psw", "d41d8cd98f00b204e9800998ecf8427e");
      dictionary.Add("MyCurrentCompany", "11B11DB4-E907-4F1F-8835-B9DAAB6E1F23");
      dictionary.Add("rememberusercode", "");
      HttpWebRequest httpWebRequest = WebRequest.Create(requestUriString) as HttpWebRequest;
      httpWebRequest.Method = "POST";
      httpWebRequest.ContentType = "application/x-www-form-urlencoded";
      StringBuilder stringBuilder = new StringBuilder();
      int num = 0;
      foreach (string key in dictionary.Keys)
      {
        if (num > 0)
          stringBuilder.AppendFormat("&{0}={1}", (object) key, (object) dictionary[key]);
        else
          stringBuilder.AppendFormat("{0}={1}", (object) key, (object) dictionary[key]);
        ++num;
      }
      byte[] bytes = Encoding.UTF8.GetBytes(stringBuilder.ToString());
      using (Stream requestStream = httpWebRequest.GetRequestStream())
        requestStream.Write(bytes, 0, bytes.Length);
      using (HttpWebResponse httpWebResponse = httpWebRequest.GetResponse() as HttpWebResponse)
      {
        using (StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream(), Encoding.UTF8))
        {
          if (streamReader.ReadToEnd().Contains("true"))
            return true;
        }
      }
      return false;
    }
  }
}
